<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('数据包浏览列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>数据库：</p>
                                <select name="dbName" th:with="type=${@dict.getType('db_generate_db_name')}" style="width:300px">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel + '-' + dict.dictValue}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('wenyanwen:generatelog:edit')}]];
        var removeFlag = [[${@permission.hasPermi('wenyanwen:generatelog:remove')}]];
        var prefix = ctx + "wenyanwen/generatelog";

        $(function() {
            var options = {
                sortName: "id",
     		    sortOrder: "desc",
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "数据包浏览",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'dbName', 
                    title : '数据库'
                },
                {
                    field : 'fileName', 
                    title : '文件名'
                },
                {
                    field : 'md5', 
                    title : 'md5'
                },
                {
                    field : 'sizeFormat',
                    title : '大小'
                },
                {
                    field : 'version',
                    title : '版本'
                },
                {
                    field : 'uploadStatus',
                    title : '上传状态',
                    formatter: function(value, row, index) {
                       if(value == 0){
                          return '未上传';
                       }else if(value == 1){
                          return '上传中';
                       }else if(value ==2){
                          return '上传成功';
                       }else if(value == -1){
                          return '上传失败'
                       }
                    }
                },
                {
                    field : 'createdUser', 
                    title : '打包用户'
                },
                {
                    field : 'createdTime', 
                    title : '打包时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.uploadStatus == 0){
                           actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="upload(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传资源平台</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function upload(id){
            $.modal.confirm('确定要吗上传到OSS并同步到资源更新平台吗?', function() {
				$.operate.post(prefix + "/upload", { "id": id});
		    })
        }

    </script>
</body>
</html>